#ifndef __EVENT_H__
#define __EVENT_H__

#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/queue.h"

/* MAIN EVENTS */
enum MAIN_EVENTS {
	KEY_EVENTS = 1 << 0,
	WIFI_EVENTS = 1 << 1,
	FM_EVENTS = 1 << 2,
};

/* SUB KEY_EVENTS */

/* SUB EVENTS */
enum SUB_WIFI_EVENTS {
	WIFI_STA_CONNECTING = 1 << 0,
	WIFI_STA_GET_IP = 1 << 1,
	WIFI_STA_CONNECTED = 1 << 2,
	WIFI_STA_DISCONNECTED = 1 << 3,
	WIFI_CLIENT_CONNECTED = 1 << 4,
	WIFI_CLIENT_DISCONNECTED = 1 << 5,
};

enum SUB_FM_EVENTS {
	FM_SEARCH_START = 1 << 0,
	FM_SEARCHING	= 1 << 1,
	FM_SEARCH_FINISH = 1 << 2,
	FM_PLAY = 1 << 3,
};

struct fm_event_struct {
	uint32_t freq;
};

struct key_event_struct {
	uint8_t key_press; 
	uint32_t key_num;
};

struct wifi_event_struct {
	uint8_t is_connect;
	uint8_t client_num;
	char ip[16];
};

struct event_struct {
	/* main event bit15~bit8 */
	/* sub event  bit7~bit0 */
	uint16_t event_type;
	union {
		struct wifi_event_struct wifi;
		struct key_event_struct key_s;		
		struct fm_event_struct fm;
	};
};

xQueueHandle evt_queue;

void event_init(void);

#endif
